/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author n.boschen, n.kaminski
 */

package MainPackage;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;


public class Nahrungsmittel {
    
    private static int maxNahrungmittelID = 0;
    
    //Alle Richtwerte pro 100g des Nahrungsmittels
    
    //Name
    private String Name;
    private int NahrungsmittelID;
    //Energietraeger
    private double kcal = 0,Broteinheiten = 0,Kohlenhydrate = 0,Eiweiss_g = 0,Cholesterin_mg = 0, Fett_g = 0, UngesFS_g = 0;

    //Mineralstoffe
    private double Natrium_mg = 0, Kalium_mg = 0, Magnesium_mg = 0, Calcium_mg = 0, Phosphor_mg = 0, Eisen_mg = 0, Zink_mg = 0;
    
    //Vitamine
    private double Vitamin_A_mueg = 0, Vitamin_B1_mg = 0, Vitamin_B2_mg = 0, Vitamin_B6_mg = 0, Vitamin_C_mg = 0, Vitamin_E_mg = 0, Folsaeure_mueg = 0, Carotin_mg = 0;
    
    public Nahrungsmittel(){};
    public Nahrungsmittel(String name, double kcal, double kohy, double brotE, double eiW, double chol, double fett, double unFett, 
                            double natr, double kali, double magn, double calc, double phosp, double eisen, double zink,
                            double vitA, double vitB1, double vitB2, double vitB6, double vitC, double vitE, double fols, double carot){
        
        this.maxNahrungmittelID+=1;
        
        this.Name = name;
        this.kcal=kcal;
        this.Broteinheiten=brotE;
        this.Kohlenhydrate=kohy;
        this.Eiweiss_g=eiW;
        this.Cholesterin_mg=chol;
        this.Fett_g=fett;
        this.UngesFS_g=unFett;
        
        this.Natrium_mg=natr;
        this.Kalium_mg=kali;
        this.Magnesium_mg=magn;
        this.Calcium_mg=calc;
        this.Phosphor_mg=phosp;
        this.Eisen_mg=eisen;
        this.Zink_mg=zink;
        
        this.Vitamin_A_mueg=vitA;
        this.Vitamin_B1_mg=vitB1;
        this.Vitamin_B2_mg=vitB2;
        this.Vitamin_B6_mg=vitB6;
        this.Vitamin_C_mg=vitC;
        this.Vitamin_E_mg=vitE;
        this.Folsaeure_mueg=fols;
        this.Carotin_mg=carot;
    };
    
    @Override
    public String toString(){
        return this.Name;
    }
    
    public void FillJTable(JTable table){
        String[] ColNames = {"Inhaltsstoff", "Wert"};
        DefaultTableModel dtm = new DefaultTableModel(ColNames, 25);
      
        
        dtm.setValueAt("Kilo Joule (kj)", 0, 0);
        dtm.setValueAt(this.getKcalAsKJoule(), 0, 1);
        dtm.setValueAt("Kilo Kalorien (kcal)", 1, 0);
        dtm.setValueAt(kcal, 1, 1);
        dtm.setValueAt("Broteinheiten", 2, 0);
        dtm.setValueAt(Broteinheiten, 2, 1);
        dtm.setValueAt("Kohlenhydrate", 3, 0);
        dtm.setValueAt(Kohlenhydrate, 3, 1);
        dtm.setValueAt("Eiweiß (g)", 4, 0);
        dtm.setValueAt(Eiweiss_g, 4, 1);
        dtm.setValueAt("Cholesterin (mg)", 5, 0);
        dtm.setValueAt(Cholesterin_mg, 5, 1);
        dtm.setValueAt("Fett (g)", 6, 0);
        dtm.setValueAt(Fett_g, 6, 1);
        dtm.setValueAt("mehrf. unges. FS (g)", 7, 0);
        dtm.setValueAt(UngesFS_g, 7, 1);
        
        dtm.setValueAt("Natrium (mg)", 9, 0);
        dtm.setValueAt(Natrium_mg, 9, 1);
        dtm.setValueAt("Kalium (mg)", 10, 0);
        dtm.setValueAt(Kalium_mg, 10, 1);
        dtm.setValueAt("Magnesium (mg)", 11, 0);
        dtm.setValueAt(Magnesium_mg, 11, 1);
        dtm.setValueAt("Calcium (mg)", 12, 0);
        dtm.setValueAt(Calcium_mg, 12, 1);
        dtm.setValueAt("Phosphor (mg)", 13, 0);
        dtm.setValueAt(Phosphor_mg, 13, 1);
        dtm.setValueAt("Eisen (mg)", 14, 0);
        dtm.setValueAt(Eisen_mg, 14, 1);
        dtm.setValueAt("Zink (mg)", 15, 0);
        dtm.setValueAt(Zink_mg, 15, 1);
        
        dtm.setValueAt("Vitamin A (µg)", 17, 0);
        dtm.setValueAt(Vitamin_A_mueg, 17, 1);
        dtm.setValueAt("Vitamin B1 (mg)", 18, 0);
        dtm.setValueAt(Vitamin_B1_mg, 18, 1);
        dtm.setValueAt("Vitamin B2 (mg)", 19, 0);
        dtm.setValueAt(Vitamin_B2_mg, 19, 1);
        dtm.setValueAt("Vitamin B6 (mg)", 20, 0);
        dtm.setValueAt(Vitamin_B6_mg, 20, 1);
        dtm.setValueAt("Vitamin C (mg)", 21, 0);
        dtm.setValueAt(Vitamin_C_mg, 21, 1);
        dtm.setValueAt("Vitamin E (mg)", 22, 0);
        dtm.setValueAt(Vitamin_E_mg, 22, 1);
        dtm.setValueAt("Folsäure (µg)", 23, 0);
        dtm.setValueAt(Folsaeure_mueg, 23, 1);
        dtm.setValueAt("Carotin (mg)", 24, 0);
        dtm.setValueAt(Carotin_mg, 24, 1);
        
        table.setModel(dtm);
    }
    
    public static void FillJTable_Empty(JTable table){
        String[] ColNames = {"Inhaltsstoff", "Wert"};
        DefaultTableModel dtm = new DefaultTableModel(ColNames, 25);
      
        
        dtm.setValueAt("Kilo Joule (kj)", 0, 0);
        dtm.setValueAt("Kilo Kalorien (kcal)", 1, 0);
        dtm.setValueAt("Broteinheiten", 2, 0);
        dtm.setValueAt("Kohlenhydrate", 3, 0);
        dtm.setValueAt("Eiweiß (g)", 4, 0);
        dtm.setValueAt("Cholesterin (mg)", 5, 0);
        dtm.setValueAt("Fett (g)", 6, 0);
        dtm.setValueAt("mehrf. unges. FS (g)", 7, 0);
        
        dtm.setValueAt("Natrium (mg)", 9, 0);
        dtm.setValueAt("Kalium (mg)", 10, 0);
        dtm.setValueAt("Magnesium (mg)", 11, 0);
        dtm.setValueAt("Calcium (mg)", 12, 0);
        dtm.setValueAt("Phosphor (mg)", 13, 0);
        dtm.setValueAt("Eisen (mg)", 14, 0);
        dtm.setValueAt("Zink (mg)", 15, 0);
        
        dtm.setValueAt("Vitamin A (µg)", 17, 0);
        dtm.setValueAt("Vitamin B1 (mg)", 18, 0);
        dtm.setValueAt("Vitamin B2 (mg)", 19, 0);
        dtm.setValueAt("Vitamin B6 (mg)", 20, 0);
        dtm.setValueAt("Vitamin C (mg)", 21, 0);
        dtm.setValueAt("Vitamin E (mg)", 22, 0);
        dtm.setValueAt("Folsäure (µg)", 23, 0);
        dtm.setValueAt("Carotin (mg)", 24, 0);
        
        table.setModel(dtm);
    }
    
    public void AddOtherNahrungsmittel(Nahrungsmittel n, int Menge_in_G)
    {
        this.kcal+= (n.kcal/100.0)*Menge_in_G;
        this.Broteinheiten+=(n.Broteinheiten/100.0)*Menge_in_G;
        this.Kohlenhydrate+=(n.Kohlenhydrate/100.0)*Menge_in_G;
        this.Eiweiss_g+=(n.Eiweiss_g/100.0)*Menge_in_G;
        this.Cholesterin_mg+=(n.Cholesterin_mg/100.0)*Menge_in_G;
        this.Fett_g+=(n.Fett_g/100.0)*Menge_in_G;
        this.UngesFS_g+=(n.UngesFS_g/100.0)*Menge_in_G;
        
        this.Natrium_mg+=(n.Natrium_mg/100.0)*Menge_in_G;
        this.Kalium_mg+=(n.Kalium_mg/100.0)*Menge_in_G;
        this.Magnesium_mg+=(n.Magnesium_mg/100.0)*Menge_in_G;
        this.Calcium_mg+=(n.Calcium_mg/100.0)*Menge_in_G;
        this.Phosphor_mg+=(n.Phosphor_mg/100.0)*Menge_in_G;
        this.Eisen_mg+=(n.Eisen_mg/100.0)*Menge_in_G;
        this.Zink_mg+=(n.Zink_mg/100.0)*Menge_in_G;
        
        this.Vitamin_A_mueg+=(n.Vitamin_A_mueg/100.0)*Menge_in_G;
        this.Vitamin_B1_mg+=(n.Vitamin_B1_mg/100.0)*Menge_in_G;
        this.Vitamin_B2_mg+=(n.Vitamin_B2_mg/100.0)*Menge_in_G;
        this.Vitamin_B6_mg+=(n.Vitamin_B6_mg/100.0)*Menge_in_G;
        this.Vitamin_C_mg+=(n.Vitamin_C_mg/100.0)*Menge_in_G;
        this.Vitamin_E_mg+=(n.Vitamin_E_mg/100.0)*Menge_in_G;
        this.Folsaeure_mueg+=(n.Folsaeure_mueg/100.0)*Menge_in_G;
        this.Carotin_mg+=(n.Carotin_mg/100.0)*Menge_in_G;
    }
    
    public double getKcalAsKJoule(){
        return kcal*4.1868;
    }
    
    //<editor-fold defaultstate="collapsed" desc="Getter & Setter für Attribute">
    public static int getMaxNahrungsmittelID(){
        return Nahrungsmittel.maxNahrungmittelID;
    }
    public static void setMaxNahrungsmittelID(int maxNahrungsmittelID){
        Nahrungsmittel.maxNahrungmittelID = maxNahrungsmittelID;
    }
    public String getName(){
        return this.Name;
    }            
    public void setName(String name){
        this.Name = name;
    }
    public int getNahrungsmittelID(){
        return this.NahrungsmittelID;
    }            
    public void setNahrungsmittelID(int NahrungsmittelID){
        this.NahrungsmittelID = NahrungsmittelID;
    }   
    public double getKcal(){
        return this.kcal;
    }
    public void setKcal(double kcal){
        this.kcal = kcal;
    }
    public double getBroteinheiten(){
        return this.Broteinheiten;
    }
    public void setBroteinheiten(double Broteinheiten){
        this.Broteinheiten = Broteinheiten;
    }
    public double getKohlenhydrate(){
        return this.Kohlenhydrate;
    }
    public void setKohlenhydrate(double Kohlenhydrate){
        this.Kohlenhydrate = Kohlenhydrate;
    }
    public double getEiweiss_g(){
        return this.Eiweiss_g;
    }
    public void setEiweiss_g(double Eiweiss_g){
        this.Eiweiss_g = Eiweiss_g;
    }
    public double getCholesterin_mg(){
        return this.Cholesterin_mg;
    }
    public void setCholesterin_mg(double Cholesterin_mg){
        this.Cholesterin_mg = Cholesterin_mg;
    }
    public double getFett_g(){
        return this.Fett_g;
    }
    public void setFett_g(double Fett_g){
        this.Fett_g = Fett_g;
    }
    public double getUngesFS_g(){
        return this.UngesFS_g;
    }
    public void setUngesFS_g(double UngesFS_g){
        this.UngesFS_g = UngesFS_g;
    }
    public double getNatrium_mg(){
        return this.Natrium_mg;
    }
    public void setNatrium_mg(double Natrium_mg){
        this.Natrium_mg = Natrium_mg;
    }
    public double getKalium_mg(){
        return this.Kalium_mg;
    }
    public void setKalium_mg(double Kalium_mg){
        this.Kalium_mg = Kalium_mg;
    }
    public double getMagnesium_mg(){
        return this.Magnesium_mg;
    }
    public void setMagnesium_mg(double Magnesium_mg){
        this.Magnesium_mg = Magnesium_mg;
    }
    public double getCalcium_mg(){
        return this.Calcium_mg;
    }
    public void setCalcium_mg(double Calcium_mg){
        this.Calcium_mg = Calcium_mg;
    }
    public double getPhosphor_mg(){
        return this.Phosphor_mg;
    }
    public void setPhosphor_mg(double Phosphor_mg){
        this.Phosphor_mg = Phosphor_mg;
    }
    public double getEisen_mg(){
        return this.Eisen_mg;
    }
    public void setEisen_mg(double Eisen_mg){
        this.Eisen_mg = Eisen_mg;
    }
    public double getZink_mg(){
        return this.Zink_mg;
    }
    public void setZink_mg(double Zink_mg){
        this.Zink_mg = Zink_mg;
    }    
    public double getVitamin_A_mueg(){
        return this.Vitamin_A_mueg;
    }
    public void setVitamin_A_mueg(double Vitamin_A_mueg){
        this.Vitamin_A_mueg = Vitamin_A_mueg;
    }
    public double getVitamin_B1_mg(){
        return this.Vitamin_B1_mg;
    }
    public void setVitamin_B1_mg(double Vitamin_B1_mg){
        this.Vitamin_B1_mg = Vitamin_B1_mg;
    }
    public double getVitamin_B2_mg(){
        return this.Vitamin_B2_mg;
    }
    public void setVitamin_B2_mg(double Vitamin_B2_mg){
        this.Vitamin_B2_mg = Vitamin_B2_mg;
    }
    public double getVitamin_B6_mg(){
        return this.Vitamin_B6_mg;
    }
    public void setVitamin_B6_mg(double Vitamin_B6_mg){
        this.Vitamin_B6_mg = Vitamin_B6_mg;
    }
    public double getVitamin_C_mg(){
        return this.Vitamin_C_mg;
    }
    public void setVitamin_C_mg(double Vitamin_C_mg){
        this.Vitamin_C_mg = Vitamin_C_mg;
    }
    public double getVitamin_E_mg(){
        return this.Vitamin_E_mg;
    }
    public void setVitamin_E_mg(double Vitamin_E_mg){
        this.Vitamin_E_mg = Vitamin_E_mg;
    }
    public double getFolsaeure_mueg(){
        return this.Folsaeure_mueg;
    }
    public void setFolsaeure_mueg(double Folsaeure_mueg){
        this.Folsaeure_mueg = Folsaeure_mueg;
    }
    public double getCarotin_mg(){
        return this.Carotin_mg;
    }
    public void setCarotin_mg(double Carotin_mg){
        this.Carotin_mg = Carotin_mg;
    }
    //</editor-fold>
}
